// Name:                     Animation
//
// Description:              Useful CSS3 animations
//
// Component:                `.am-animation-*`
//
// Modifiers:                `.am-animation-fade`
//                           `.am-animation-scale-up`
//                           `.am-animation-scale-down`
//                           `.am-animation-slide-top`
//                           `.am-animation-slide-bottom`
//                           `.am-animation-slide-left`
//                           `.am-animation-slide-right`
//                           `.am-animation-slide-shake`
//                           `.am-animation-reverse`
//
// Used by:                  Dropdown
//
// =============================================================================


/* ==========================================================================
   Component: Aniamtion
 ============================================================================ */

[class*='am-animation-'] {
  -webkit-animation-duration: 0.5s;
  animation-duration: 0.5s;
  -webkit-animation-timing-function: ease-out;
  animation-timing-function: ease-out;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}


/* Hide animated element if scrollspy is used */

@media screen {
  .cssanimations [data-am-scrollspy*='animation'] {
    opacity: 0;
  }
}


/* Fade */

.am-animation-fade {
  -webkit-animation-name: am-fade;
  animation-name: am-fade;
  -webkit-animation-duration: 0.8s;
  animation-duration: 0.8s;
  -webkit-animation-timing-function: linear;
  animation-timing-function: linear;
}


/* Scale */

.am-animation-scale-up {
  -webkit-animation-name: am-scale-up;
  animation-name: am-scale-up;
}

.am-animation-scale-down {
  -webkit-animation-name: am-scale-down;
  animation-name: am-scale-down;
}


/* Slide */

.am-animation-slide-top {
  -webkit-animation-name: am-slide-top;
  animation-name: am-slide-top;
}

.am-animation-slide-bottom {
  -webkit-animation-name: am-slide-bottom;
  animation-name: am-slide-bottom;
}

.am-animation-slide-left {
  -webkit-animation-name: am-slide-left;
  animation-name: am-slide-left;
}

.am-animation-slide-right {
  -webkit-animation-name: am-slide-right;
  animation-name: am-slide-right;
}

.am-animation-slide-top-fixed {
  -webkit-animation-name: am-slide-top-fixed;
  animation-name: am-slide-top-fixed;
}


/* Shake */

.am-animation-shake {
  -webkit-animation-name: am-shake;
  animation-name: am-shake;
}


/* Spin */
.am-animation-spin {
  .animation(am-spin 2s infinite linear);
}

.am-animation-left-spring {
  .animation(am-left-spring .3s ease-in-out);
}

.am-animation-right-spring {
  .animation(am-right-spring .3s ease-in-out);
}


// Modifiers
// =============================================================================

.am-animation-reverse {
  -webkit-animation-direction: reverse;
  animation-direction: reverse;
}

.am-animation-paused {
  -webkit-animation-play-state: paused !important;
  animation-play-state: paused !important;
}


/* Keyframes
 ============================================================================ */

/* Fade */

@-webkit-keyframes am-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes am-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}


/* Scale up */

@-webkit-keyframes am-scale-up {
  0% {
    opacity: 0;
    -webkit-transform: scale(0.2);
  }

  100% {
    opacity: 1;
    -webkit-transform: scale(1);
  }
}

@keyframes am-scale-up {
  0% {
    opacity: 0;
    transform: scale(0.2);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}


/* Scale down */

@-webkit-keyframes am-scale-down {
  0% {
    opacity: 0;
    -webkit-transform: scale(1.8);
  }

  100% {
    opacity: 1;
    -webkit-transform: scale(1);
  }
}

@keyframes am-scale-down {
  0% {
    opacity: 0;
    transform: scale(1.8);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}


/* Slide top */

@-webkit-keyframes am-slide-top {
  0% {
    opacity: 0;
    -webkit-transform: translateY(-100%);
  }

  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
  }
}

@keyframes am-slide-top {
  0% {
    opacity: 0;
    transform: translateY(-100%);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Slide bottom */

@-webkit-keyframes am-slide-bottom {
  0% {
    opacity: 0;
    -webkit-transform: translateY(100%);
  }

  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
  }
}

@keyframes am-slide-bottom {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Slide left */

@-webkit-keyframes am-slide-left {
  0% {
    opacity: 0;
    -webkit-transform: translateX(-100%);
  }

  100% {
    opacity: 1;
    -webkit-transform: translateX(0);
  }
}

@keyframes am-slide-left {
  0% {
    opacity: 0;
    transform: translateX(-100%);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}


/* Slide right */

@-webkit-keyframes am-slide-right {
  0% {
    opacity: 0;
    -webkit-transform: translateX(100%);
  }

  100% {
    opacity: 1;
    -webkit-transform: translateX(0);
  }
}

@keyframes am-slide-right {
  0% {
    opacity: 0;
    transform: translateX(100%);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}


/* Shake */

@-webkit-keyframes am-shake {
  0%, 100% { -webkit-transform: translateX(0); }
  10% { -webkit-transform: translateX(-9px); }
  20% { -webkit-transform: translateX(8px); }
  30% { -webkit-transform: translateX(-7px); }
  40% { -webkit-transform: translateX(6px); }
  50% { -webkit-transform: translateX(-5px); }
  60% { -webkit-transform: translateX(4px); }
  70% { -webkit-transform: translateX(-3px); }
  80% { -webkit-transform: translateX(2px); }
  90% { -webkit-transform: translateX(-1px); }
}

@keyframes am-shake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-9px); }
  20% { transform: translateX(8px); }
  30% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  50% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
  90% { transform: translateX(-1px); }
}


/* Slide top fixed */

@-webkit-keyframes am-slide-top-fixed {
  0% {
    opacity: 0;
    -webkit-transform: translateY(-10px);
  }

  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
  }
}

@keyframes am-slide-top-fixed {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Slide bottom fixed */

@-webkit-keyframes am-slide-bottom-fixed {
  0% {
    opacity: 0;
    -webkit-transform: translateY(10px);
  }

  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
  }
}

@keyframes am-slide-bottom-fixed {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Spin */

@-webkit-keyframes am-spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(359deg); }
}

@keyframes am-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(359deg); }
}


/* Spring */

@-webkit-keyframes am-right-spring {
  0% {
    .translate();
  }
  50% {
    .translate(-20%)
  }
  100% {
    .translate();
  }
}

@keyframes am-right-spring {
  0% {
    .translate();
  }
  50% {
    .translate(-20%)
  }
  100% {
    .translate();
  }
}

@-webkit-keyframes am-left-spring {
  0% {
    .translate();
  }
  50% {
    .translate(20%);
  }
  100% {
    .translate();
  }
}

@keyframes am-left-spring {
  0% {
    .translate();
  }
  50% {
    .translate(20%);
  }
  100% {
    .translate();
  }
}